package momo.app.comms;

import java.util.concurrent.Callable;

import momo.app.structure.Message;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


public class LostMsgCheckerTask implements Callable<String>
{
	private Log log = LogFactory.getLog(LostMsgCheckerTask.class);
	
	private String sourceId;
	private int localSeqNo;
	private StringBuffer buffer;
	
	public LostMsgCheckerTask(String sourceId, int localSeqNo)
	{
		this.sourceId = sourceId;
		this.localSeqNo = localSeqNo;
		buffer = new StringBuffer();
		buffer.append(sourceId);
		buffer.append(",");
		buffer.append(localSeqNo);
	}
	
	public String call() throws Exception
	{
		Message m = CommsHistory.getInstance().getMessage(sourceId, localSeqNo);
		if ( m == null )
		{
			if ( log.isDebugEnabled() )
				log.debug("Msg seq: " + localSeqNo +", of source: " + sourceId + " is NOT available");
			return buffer.toString();
		}else
		{
			if ( log.isDebugEnabled() )
				log.debug("Msg seq: " + localSeqNo +", of source: " + sourceId + " IS available");
			return "";
		}
	}
	
}//end of class LostMsgCheckerTask
